<?php

/**
 * This is the model class for table "Usuarios.usuarios".
 *
 * The followings are the available columns in table 'Usuarios.usuarios':
 * @property string $id_usuario
 * @property string $fechaa
 * @property string $id_tipo
 * @property string $matricula
 * @property string $correo
 * @property string $titulo
 * @property string $nombres
 * @property string $apellidop
 * @property string $apellidom
 * @property integer $id_area
 * @property string $puesto
 * @property string $nombre_usuario
 * @property string $contrasenia
 *
 * The followings are the available model relations:
 * @property Area $idArea
 * @property Tipos $idTipo
 */
class UsuariosExternos extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'Usuarios.usuarios';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_area', 'numerical', 'integerOnly'=>true),
			array('id_tipo, titulo', 'length', 'max'=>5),
			array('matricula', 'length', 'max'=>8),
			array('correo', 'length', 'max'=>60),
			array('nombres', 'length', 'max'=>50),
			array('apellidop, apellidom, nombre_usuario', 'length', 'max'=>20),
			array('puesto', 'length', 'max'=>40),
			array('contrasenia', 'length', 'max'=>32),
			array('fechaa', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id_usuario, fechaa, id_tipo, matricula, correo, titulo, nombres, apellidop, apellidom, id_area, puesto, nombre_usuario, contrasenia', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idArea' => array(self::BELONGS_TO, 'Area', 'id_area'),
			'idTipo' => array(self::BELONGS_TO, 'Tipos', 'id_tipo'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_usuario' => 'Id Usuario',
			'fechaa' => 'Fechaa',
			'id_tipo' => 'Id Tipo',
			'matricula' => 'Matricula',
			'correo' => 'Correo',
			'titulo' => 'Titulo',
			'nombres' => 'Nombres',
			'apellidop' => 'Apellidop',
			'apellidom' => 'Apellidom',
			'id_area' => 'Id Area',
			'puesto' => 'Puesto',
			'nombre_usuario' => 'Nombre Usuario',
			'contrasenia' => 'Contrasenia',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_usuario',$this->id_usuario,true);
		$criteria->compare('fechaa',$this->fechaa,true);
		$criteria->compare('id_tipo',$this->id_tipo,true);
		$criteria->compare('matricula',$this->matricula,true);
		$criteria->compare('correo',$this->correo,true);
		$criteria->compare('titulo',$this->titulo,true);
		$criteria->compare('nombres',$this->nombres,true);
		$criteria->compare('apellidop',$this->apellidop,true);
		$criteria->compare('apellidom',$this->apellidom,true);
		$criteria->compare('id_area',$this->id_area);
		$criteria->compare('puesto',$this->puesto,true);
		$criteria->compare('nombre_usuario',$this->nombre_usuario,true);
		$criteria->compare('contrasenia',$this->contrasenia,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return UsuariosExternos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
